﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Common;

namespace KendoMvcUI.UI
{
    public class AnimationSettings
    {
        public AnimationSettings()
        {
            Open=new EffectsSettings();
            Close=new EffectsSettings();
        }

        public EffectsSettings Open { get; set; }
        public EffectsSettings Close { get; set; }
        public override string ToString()
        {
            var animation = "";
            if(Open!=null)
            {
                var open = Open.ToString();
                if(!open.IsNullOrWhiteSpace())
                    animation+="open:{"+open+"},";
            }
            if (Close != null)
            {
                var close = Close.ToString();
                if (!close.IsNullOrWhiteSpace())
                    animation += "close:{" + close + "}";
            }

            return "animation:{" + animation.TrimEnd(',') + "}";
        }
    }
    public class EffectsSettings
    {
        public string Effects { get; set; }
        public int? Duration { get; set; }

        public override string ToString()
        {
            var effects="";
            if (!Effects.IsNullOrWhiteSpace())
                effects += "effects:'{0}'，".Formator(Effects);
            if (Duration.HasValue)
                effects += "duration:{0}".Formator(Duration);

            return effects.TrimEnd(',');
        }
    }
}
